from app import app
from views.weatherView import get_location
import pytest
        
        
@pytest.fixture
def client():
    app.config['TESTING'] = True
    with app.test_client() as client:
        yield client
        
def test_weather(client):
    response = client.get("/weather/广州")
    assert response.status_code == 200
    
def test_weather_not_found(client):
    response = client.get("/weather/123")
    response_json = response.get_json()
    assert response_json.get('message', None) == "Other error occurred: 'location'"
    

def test_weather_me(client):
    response = client.get("/weather/me")
    response_json = response.get_json()
    assert response.status_code == 200
    assert response_json["city"] == get_location()